export interface CformPropsType {
  formParams?: any;
  cformOpt: CFormOptType;
  id?: string;
}
export const formProps = ["formParams", "cformOpt", "id"];
export const formEmit = ["changeProps", "changeRadio", "beforeSubmit", "beforeUpload", "otherGetFileFn"];
export class formData {
  props: CformPropsType;
  emit;
  formPropsObj: any = {};
  constructor(props: CformPropsType, emit: (event: string, ...args: any[]) => void) {
    this.emit = emit;
    this.props = props;
    formProps.map((item) => {
      this.formPropsObj[item] = props[item as keyof CformPropsType];
    });
  }
  formEmitsObj = {
    beforeSubmit: ({ submitData, fn }: { submitData: any; fn: void }) => {
      this.emit("beforeSubmit", { submitData, fn });
    },
    changeRadio: ({ e, key, item, form }: changeRadioFormType) => {
      this.emit("changeRadio", { e, key, item, form });
    },
    beforeUpload: ({ file, type, item, fileProp }) => {
      this.emit("beforeUpload", { file, type, item, fileProp });
    },
    otherGetFileFn: ({ e, props }) => {
      this.emit("otherGetFileFn", { e, props });
    },
    changeProps: ({ e, propsName }) => {
      this.emit("changeProps", { e, propsName });
    }
  };
}
export const fileType = ["uAudio", "uVideo", "uImg", "uImgs", "uFile"];
